//
//  SLSelectAccessTypeVC.m
//  SlockApp
//
//  Created by 凯朱 on 2024/7/25.
//

#import "SLSelectAccessTypeVC.h"
#import "SLSetAccessNameVC.h"
@interface SLSelectAccessTypeVC ()

@end

@implementation SLSelectAccessTypeVC
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpSubViews];
}

-(void)setUpSubViews{
    self.title = kLocalString(@"Make new access");
    _tipLbl.text = kLocalString(@"Select an access type");
    
    _bgView.layer.cornerRadius = 20;
    _bgView.layer.masksToBounds = YES;
    
    _listLbl1.text = kLocalString(@"Permanent");
    _listTipLbl1.text = kLocalString(@"Unlock without time limitation.");
    _listLbl2.text = kLocalString(@"Duration");
    _listTipLbl2.text = kLocalString(@"Access with time duration limits.");
    _listLbl3.text = kLocalString(@"One-time");
    _listTipLbl3.text = kLocalString(@"Unlock only once.");
    
    kWeakSelf(self);
    _listView1.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [weakself handleListAction:1];
    }];
    [_listView1 addGestureRecognizer:tap1];
    
    _listView2.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [weakself handleListAction:2];
    }];
    [_listView2 addGestureRecognizer:tap2];
    
    _listView3.userInteractionEnabled = YES;
    _listView3.hidden = YES;
    _line2.hidden = YES;
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        [weakself handleListAction:3];
    }];
    [_listView3 addGestureRecognizer:tap3];
    
}

-(void)handleListAction:(NSInteger)index{
    _keyModel.keyType = index;
    SLSetAccessNameVC *vc = [[SLSetAccessNameVC alloc] init];
    vc.keyModel = _keyModel;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
